#ifndef SINGLETON_H
#define SINGLETON_H

#include <QMutex>

#define SINGLETON_DECLARE(classname) \
    public: \
        static classname* getInstance() \
        { \
            if (m_instance == nullptr) \
            { \
                QMutexLocker cLocker(&m_getInstanceMutex); \
                if(m_instance == nullptr) \
                    m_instance = new classname(); \
            } \
            return m_instance; \
        } \
    private: \
        static classname* m_instance; \
        static QMutex m_getInstanceMutex;

#define SINGLETON_IMPLIMENT(classname) \
    classname* classname::m_instance = nullptr; \
    QMutex classname::m_getInstanceMutex;


#endif // SINGLETON_H
